From 337359afdf0a561eaa5826a4e09df5aa8b78a99f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Jun 2017 07:00:17 -0700 Subject: [PATCH] Try to not allocate when decoding registry json There's a few keys we don't need owned versions of, so try using Serde's zero-copy deserialization where we can. --- src/cargo/sources/registry/mod.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 5319c4bfe..139d8a607 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -158,6 +158,7 @@ //! ... //! ``` +use std::borrow::Cow; use std::collections::HashMap; use std::fs::File; use std::path::{PathBuf, Path}; @@ -198,24 +199,24 @@ pub struct RegistryConfig { } #[derive(Deserialize)] -struct RegistryPackage { +struct RegistryPackage<'a> { name: String, vers: String, - deps: Vec, + deps: Vec>, features: HashMap>, cksum: String, yanked: Option, } #[derive(Deserialize)] -struct RegistryDependency { - name: String, - req: String, +struct RegistryDependency<'a> { + name: Cow<'a, str>, + req: Cow<'a, str>, features: Vec, optional: bool, default_features: bool, - target: Option, - kind: Option, + target: Option>, + kind: Option>, } pub trait RegistryData { -- 2.30.2